//
//  YKClientExchangeManagerController.m
//  YunKang
//
//  Created by leoking870 on 2017/10/15.
//  Copyright © 2017年 leoking870. All rights reserved.
//

#import "YKClientExchangeManagerController.h"
#import "YKClientListHeaderView.h"
#import "YKClientDrugPriceModelItem.h"
#import "YKClientExchangeDetailViewController.h"
#import "YKClientExchangeItem.h"
#import "YKClientExchangeV2Item.h"
@interface YKClientExchangeManagerController ()

@end

@implementation YKClientExchangeManagerController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.title = @"积分兑换审批";
//    YKClientListHeaderView* headerView = [[YKClientListHeaderView alloc]initWithTitles:@[@"申请单号",@"客户名称",@"申请日期",@"状态"] weights:@[@3,@3,@2,@2]];
//    headerView.backgroundColor = [UIColor tf_colorWithHexString:@"#1EADFC"];
//    [self.view addSubview:headerView];
//
//    headerView.textColor = [UIColor whiteColor];
//    headerView.textFont = [UIFont systemFontOfSize:16];
//    [headerView mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.leading.top.trailing.equalTo(self.view);
//    }];
    
    self.tableView.separatorStyle = UITableViewCellSeparatorStyleSingleLine;
    
    [self.tableView mas_remakeConstraints:^(MASConstraintMaker *make) {
//        make.leading.trailing.equalTo(self.view);
//        make.top.equalTo(headerView.mas_bottom);
//        make.bottom.equalTo(self.view.mas_bottom);
        make.edges.equalTo(self.view);
        
    }];
    self.dataSource.totalPageKey = @"page.totalpage";
    self.dataSource.currentPageKey = @"curpage";
    [self startLoadData];
}


- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    if (self.dataSource.manager.sections.count > 0) {
        [self startLoadDataSilently];
    }
}
- (void)beginSearchWithText:(NSString *)text {
    [self startLoadData];
}
- (NSDictionary *)pageViewControllerParameters {
    return @{
             kTFPageViewControllerItemClass: [YKClientExchangeV2Item class],
             kTFPageViewControllerModelClass:[YKClientExchangeModel class],
             kTFPageViewControllerRequestURL:@"customerPointsExchange/customerPointsExchangeList.htm",
             kTFPageViewControllerDataKeyPath:@"list",
             kTFPageViewControllerRequestParameter:@{@"c_name":[self searchText]}
             };
}
- (void)customizeItem:(TFTableViewItem *)item {
    @weakify(self)
    item.hideSeparator = NO;
    item.separatorSunk = NO;
    item.selectionHandler = ^(__kindof YKClientExchangeItem *item, NSIndexPath *indexPath) {
        YKClientExchangeDetailViewController *vc = [[YKClientExchangeDetailViewController alloc]init];
        vc.m_id = item.model.ID;
        [self_weak_.navigationController pushViewController:vc animated:YES];
    };
}
@end
